#Powershell Oneliner: Delete Personal / Machine Certificates

While searching for a solution to delete a personal machine certificate, I again found Powershell to provide the best solution.

Let´s say you have a machine certificate Issued by CA “testca.domain.bla” and want to delete it. This is solved in a one liner in Powershell Version 3:

 

get-childitem -path cert:\localmachine\my | where {$_.Issuer -like ‘*testca*’} | remove-item

In Powershell Version 4, you could also use:

Get-ChildItem -Path cert:\LocalMachine\my -DnsName *domain* | Remove-Item

to remove all Certificates with the dnsname *domain* in the name.

The parameter “DnsName” was introduced with Powershell Version 4.

Instead of the path cert:\LocalMachine you could use cert:\CurrentUser for the User certificates.

Once again PowerShell ISE will help you find your way by autosensing even the certificate paths!

Really easy!

 

more at TechNet

Leave a comment